#pragma once
#include "../QbBondDefines.h"
#include <qbprotocol/include/SSQBModel.h>
#include <QWidget>
//#include <QStylePainter>
#include <vector>

class QScrollBar;
class BondDealMatrixImpl;
class BondDealMatrixData;
class S_QBBOND_EXPORT BondDealMatrix : public QWidget
{
public:
	enum eWndType {
		eWndTypeFixedIncome = 0,//固收综合屏
		eWndTypeBondDealStatistics //成交统计
	};

	enum eMatrixType {
		eMTFixedIncomeGov = 1,
		eMTFixedIncomeCredit,
		eMTFixedIncomeNCDPrimary,
		eMTFixedIncomeNCD,
		eMTBondDealGov,
		eMTBondDealCredit,
		eMTBondDealNCD
	};

	enum eGovBondType {
		eTypeCountry = 1,//国债
		eTypeCBDBond,//国开
		eTypeEximBank,//口行
		eTypeADBC,//农发
		eTypeOtherPolicy,//非国开
		eTypeMunicipal,//地方债
		eTypeCount
	};

	enum eCreditBondRate {
		eRateAAAP = 1,
		eRateAAA,
		eRateAAP,
		eRateAA,
		eRateAAR,//AA-，仅NCD一级报价使用
		eRateOther,//AA-及以下
		eRateCount
	};

	enum eGovBondTerm {
		eGovTerm1Y = 1,
		eGovTerm2Y,
		eGovTerm3Y,
		eGovTerm5Y,
		eGovTerm7Y,
		eGovTerm10Y,
		eGovTerm15Y,
		eGovTerm20Y,
		eGovTerm30Y,
		eGovTerm50Y,
		eGovTermLong,
		eGovTermCount
	};

	enum eCreditBondTerm {
		eCreditTerm1M = 1,
		eCreditTerm3M,
		eCreditTerm6M,
		eCreditTerm1Y,
		eCreditTerm2Y,
		eCreditTerm3Y,
		eCreditTerm4Y,
		eCreditTerm5Y,
		eCreditTerm7Y,
		eCreditTerm10Y,
		eCreditTermCount
	};

	enum eNCDTerm {
		eNCDTerm15D = 1,
		eNCDTerm1M,
		eNCDTerm2M,
		eNCDTerm3M,
		eNCDTerm6M,
		eNCDTerm9M,
		eNCDTerm1Y,
		eNCDTermCount
	};

	static const int m_MaxCountCount = 12;
public:
	BondDealMatrix(QWidget* p);

	void setMatrixType(int type);
	int getMatrixType();

	void setMatrixData(BondDealMatrixData* pdata);
	void reloadData();
	void updateCell(std::map<int, int>& mapCell);
	void updateMatrix(int type);
	void setDiffCDC(int diffType);
protected:
	virtual void resizeEvent(QResizeEvent*) override;

	void resize();

protected Q_SLOTS:
	void onScrollChange(int pos);

private:
	QScrollBar* m_scroll = nullptr;//水平滚动条
	BondDealMatrixImpl* m_impl = nullptr;
};